<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>求阶乘</title>
	</head>
	<body>
 
<p>请输入数字：</p> 
 <input type="text" id="num">
 <br />
 <br />
<input type="button" id="cal" value="计算" onclick="fac();">
<br/>
<br/>
<p id="result"></p>
 <script>
function fac(){
	var x=document.getElementById('num').value;
	var result=1;
	for(var i=1;i<=x;i++){
	  result = i*result;
	}
document.getElementById("result").innerHTML=result
}

</script>

	</body>
</html>
